﻿<UserControl x:Class="BingVis.SilverlightClient.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:com="clr-namespace:BingVis.SilverlightClient.Common;assembly=BingVis.SilverlightClient.Common"
    xmlns:local="clr-namespace:BingVis.SilverlightClient"    
    xmlns:cal="clr-namespace:Microsoft.Practices.Composite.Presentation.Commands;assembly=Microsoft.Practices.Composite.Presentation"
    xmlns:map="clr-namespace:Microsoft.VirtualEarth.MapControl;assembly=Microsoft.VirtualEarth.MapControl"
    xmlns:visualizationToolkit="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit"
    xmlns:chartingToolkit="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"    
    HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
    <UserControl.Resources>
        <ResourceDictionary>
            <Style x:Key="MenuButtonStyle" TargetType="Button">
                <Setter Property="Cursor" Value="Hand"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="Button">
                            <Border
                                CornerRadius="4"
                                Margin="6 3"
                                VerticalAlignment="Stretch"                                
                                Background="{StaticResource DarkSlateGrayBrush}"
                                >
                                    <TextBlock FontWeight="Bold" Foreground="WhiteSmoke" Text="{TemplateBinding Content}"></TextBlock>
                                </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </ResourceDictionary>
    </UserControl.Resources>


    <Grid Background="#282828">                    
        <StackPanel
            Background="{StaticResource DarkSlateGrayBrush}"
            VerticalAlignment="Top"
            HorizontalAlignment="Left"
            Height="20"
            Orientation="Horizontal">
            <Button
                Content="Load Another File..."
                cal:Click.Command="{Binding ShowCompressedFareFileSelector}"
                Style="{StaticResource MenuButtonStyle}">                
                </Button>
            <Button
                Content="Compress a File..."
                Click="CompressButton_Click"
                Style="{StaticResource MenuButtonStyle}">                
                </Button>
            <Button
                Content="Help"
                cal:Click.Command="{Binding ShowBasicHelp}"
                Style="{StaticResource MenuButtonStyle}">                
            </Button>
            <Button
                Content="About"
                cal:Click.Command="{Binding ShowAbout}"
                Style="{StaticResource MenuButtonStyle}">                
            </Button>
            
            <!--<Button
                Content="Install"
                Click="Install_Click"
                Style="{StaticResource MenuButtonStyle}">
            </Button>-->

        </StackPanel>
        <!--<Menu
        Background="{StaticResource DarkGrayBrush}"
        VerticalAlignment="Top"
        HorizontalAlignment="Stretch"        
        Height="20"
        Foreground="WhiteSmoke">
            <Menu.Items>
                <MenuItem Header="File" Background="{StaticResource DarkGrayBrush}" Foreground="LightGray">
                    <MenuItem Background="{StaticResource DarkGrayBrush}" Foreground="LightGray"
                        Header="Load Fare Gate File" Command="{Binding ShowFareFileSelector}" />
                    <MenuItem Background="{StaticResource DarkGrayBrush}" Foreground="LightGray"
                        Header="Load Compressed Fare Gate File" Command="{Binding ShowCompressedFareFileSelector}" />
                    <MenuItem Background="{StaticResource DarkGrayBrush}" Foreground="LightGray"
                        Header="Compress Fare Gate File" Command="{Binding ShowCompressFileSelector}" />
                </MenuItem>
                <MenuItem Header="View" Background="{StaticResource DarkGrayBrush}" Foreground="LightGray">
                    <MenuItem IsCheckable="True" IsChecked="{Binding Show3DBuildings}" Background="{StaticResource DarkGrayBrush}" Foreground="LightGray"
                        Header="Show/Hide 3D Buildings" Command="{Binding ToggleShow3DBuildings}" CommandParameter="{Binding Show3DBuildings}" />
                </MenuItem>
                <MenuItem Header="Help" Background="{StaticResource DarkGrayBrush}" Foreground="LightGray">
                    <MenuItem Background="{StaticResource DarkGrayBrush}" Foreground="LightGray"
                        Header="Basic Help" Command="{Binding ShowBasicHelp}" />
                    <MenuItem Background="{StaticResource DarkGrayBrush}" Foreground="LightGray"
                        Header="About..." Command="{Binding ShowAbout}" />
                </MenuItem>
            </Menu.Items>
        </Menu>-->
        <Grid x:Name="LayoutRoot" Style="{StaticResource LayoutRootStyle}" Margin="0 20 0 3">

            <Grid.RowDefinitions>
                <RowDefinition Height="80*" />
                <RowDefinition Height="20*" MaxHeight="300" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="35*" MaxWidth="350" />
                <ColumnDefinition Width="65*" />
            </Grid.ColumnDefinitions>

            <!-- Left Pane -->
            <Border Style="{StaticResource LeftPaneStyle}"
            Grid.Column="0"
            Grid.Row="0"            
            >
                <Grid>
                    <TextBox
                        x:Name="txtFilter"
                        HorizontalAlignment="Stretch"
                        VerticalAlignment="Top"
                        Margin="0 0 60 0"
                        Height="20"                        
                        Foreground="Black"
                        Background="LightGray"                                    
                        KeyUp="TextBox_KeyUp"                        
                        Text="{Binding StopsFilter, Mode=TwoWay}">
                        <!--cinch:SingleEventCommand.RoutedEventName="KeyDown"
                        cinch:SingleEventCommand.TheCommandToRun="{Binding FilterOnEnter}"-->
                        
                        <ToolTipService.ToolTip>
                            <StackPanel>
                                <TextBlock Foreground="Black" Text="'&lt;search filter&gt;' or '$ &lt;search filter&gt;' to show only stops with fares."></TextBlock>
                            </StackPanel>
                        </ToolTipService.ToolTip>
                    </TextBox>

                    <Button
                        HorizontalAlignment="Right"
                        VerticalAlignment="Top"
                        Height="20"
                        Width="50"
                        Content="Filter"
                        cal:Click.Command="{Binding StopsList.FilterStops}"
                        cal:Click.CommandParameter="{Binding StopsFilter}"/>
                    <ScrollViewer
                        Margin="0 25 0 0"
                        VerticalAlignment="Stretch"
                        HorizontalAlignment="Stretch"
                        HorizontalScrollBarVisibility="Hidden"
                        >
                        <ItemsControl
                            Style="{StaticResource StopsListStyle}"
                            ItemsSource="{Binding StopsList.Stops}">
                        </ItemsControl>
                    </ScrollViewer>
                </Grid>
            </Border>

            <!-- Map Pane -->
            <Border Style="{StaticResource MapPaneStyle}"
            
            Grid.Column="1"
            Grid.Row="0"
            >
                <Grid
                 HorizontalAlignment="Stretch"                 
                 x:Name="MapGrid">

                    <!-- InfoStra.VE (BingMaps3d) Map Control -->
                    <!--<ve:VEMap
                    x:Name="Map"
                    local:Bing3dMapBehaviors.Show3DBuildings="{Binding Show3DBuildings}"                    
                    HorizontalAlignment="Stretch"
                    VerticalAlignment="Stretch"                                        
                    HorizontalContentAlignment="Stretch"
                    Width="{Binding ElementName=MapGrid, Path=ActualWidth}"
                    local:Bing3dMapBehaviors.StartupLatLong="{Binding StartupLatLong}"
                    local:Bing3dMapBehaviors.FlyLatLong="{Binding CurrLatLong}" />-->
                    <!--ItemsSource="{Binding StopsList.Stops, Converter={StaticResource StopToPushPinCvt}}"-->
                    
                    <map:Map                                                 
                        x:Name="Map"/>
                </Grid>
            </Border>

            <!-- Bottom Pane -->
            <Border Style="{StaticResource BottomPaneStyle}"
            
            Grid.Column="0" Grid.ColumnSpan="2"
            Grid.Row="1"            
            >
                <Grid Name="ChartParent" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                    <TextBlock 
                        x:Name="LoadingText" 
                        Text="Loading..." 
                        Foreground="White" 
                        Opacity="0" 
                        Visibility="{Binding LoadingVis}" 
                        >
                    </TextBlock>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                        <TextBlock
                            Text="Showing "
                            Foreground="White"/>
                        <TextBlock                            
                            Text="{Binding FaresList.FormattedFaresTotal}"
                            Foreground="White"
                            />
                        <TextBlock
                            Text=" in Fares"
                            Foreground="White"/>
                    </StackPanel>
                    <chartingToolkit:Chart
                        Margin="0 20 0 0"                        
                        HorizontalAlignment="Stretch"
                        VerticalAlignment="Stretch" Style="{StaticResource ChartStyle1}">
                        
                        <chartingToolkit:AreaSeries
                            Title="Fares By Time"
                            ItemsSource="{Binding FaresList.Fares}"
                            DependentValuePath="FareTotal"
                            IndependentValuePath="QuarterHour" Style="{StaticResource AreaSeriesStyle1}"
                            >

                        </chartingToolkit:AreaSeries>
                        <chartingToolkit:Chart.Axes>
                            <chartingToolkit:LinearAxis
                            ShowGridLines="False"
                            Title="Fare Total"                            
                            Orientation="Y"
                            Minimum="0"                            
                            Foreground="White"
                            />
                            <chartingToolkit:DateTimeAxis
                            Title="Time of Day"
                            Orientation="X">
                                <chartingToolkit:DateTimeAxis.AxisLabelStyle>
                                    <Style TargetType="chartingToolkit:DateTimeAxisLabel">
                                        <Setter Property="StringFormat" Value="{}{0:t}" />
                                        <Setter Property="Foreground">
                                            <Setter.Value>
                                                <SolidColorBrush Color="White"></SolidColorBrush>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </chartingToolkit:DateTimeAxis.AxisLabelStyle>
                            </chartingToolkit:DateTimeAxis>
                        </chartingToolkit:Chart.Axes>
                    </chartingToolkit:Chart>
                </Grid>
            </Border>

        </Grid>
    </Grid>
</UserControl>
